package marshallerTest;

import java.io.*;

import org.exolab.castor.xml.*;


public class ZhuwTest

{

	public static void main(String[] argv) {

		// build a test bean

		FlightBean bean = new FlightBean();

		bean.setCarrier("AR");

		bean.setNumber(426);

		bean.setDepartureTime("6:23a");

		bean.setArrivalTime("8:42a");

		try {

			// write it out as XML

			File file = new File("d:\\test.xml");

			Writer writer = new FileWriter(file);

			Marshaller.marshal(bean, writer);

			// now restore the value and list what we get

			Reader reader = new FileReader(file);

			FlightBean read = (FlightBean)Unmarshaller.unmarshal(FlightBean.class, reader);
			
			System.out.println("Flight " + read.getCarrier() +

			read.getNumber() + " departing at " +

			read.getDepartureTime() +

			" and arriving at " + read.getArrivalTime());

		} catch (IOException ex) {

			ex.printStackTrace(System.err);

		} catch (MarshalException ex) {

			ex.printStackTrace(System.err);

		} catch (ValidationException ex) {

			ex.printStackTrace(System.err);

		}

//		StringBuffer sb = new StringBuffer(20);
//		sb.append("abcd");
//		sb.deleteCharAt(sb.length()-1);
//		sb.append("z");
//		System.out.println(sb.toString());
	}

}

